home *** CD-ROM | disk | FTP | other *** search
/ MacPeople 2003 February 1 / MACPEOPLE-2003-02-01.ISO.7z / MACPEOPLE-2003-02-01.ISO / ぶらりオンラインウェアの旅 / 定番ソフト / Jedit(OS9) / MacroCollectionJ.sea / MacroCollection-J / パラグラフ番号付加 / ƒ / ースリスト説明 next >
Text File  |  2001-01-01  |  3KB  |  70 lines

  1. パラグラフ番号付加マクロ
  2. programmed by Satoshi Matsumoto <satoshi@matsumoto.co.jp>
  3. 選択領域にある各パラグラフの先頭にパラグラフ番号を付加します。
  4. 領域を選択していないときは、全パラグラフにパラグラフ番号を付加します。
  5. パラグラフ番号の書式(桁数、色、文字サイズ、フォント)はこのスクリプトの先頭で指定できます。
  6.  
  7. <--cut-->
  8. property numLen : 6     桁数
  9. property padding : "0"    桁数に満たないときに埋め込むマーク
  10. property numFace : plain   スタイル
  11. property numColor : {30000, 0, 0}   文字色、RGB値
  12. property numSize : 9          文字サイズ
  13. property numFont : "Osaka"       文字フォント
  14.  
  15. tell application "Jedit4"
  16.     Jeditのバージョンが4.0.4以上かどうかをチェック。そうでない時は中止。
  17.     if version < 404 then
  18.         preDialog
  19.         display dialog "Jedit4.0 Rev4.0.4 以降を使用してください" buttons {" 了解"}
  20.         postDialog
  21.         error number -128
  22.     end if
  23.     activate          Jeditのウィンドウを全面へ
  24.     何にもウィンドウが開いていないときは、警告をだしてキャンセル
  25.     if (count document) < 1 then
  26.         preDialog
  27.         display dialog "行番号を付加する書類を先に開いてください。" buttons {" 了解"}
  28.         postDialog
  29.         error number -128   このマクロを中止する
  30.     end if
  31.     tell document 1
  32.         選択域の先頭腹グラフ番号と、終了パラグラフ番号をセット。
  33.         if length of selection < 1 then
  34.             なにも領域が選択されていないとき
  35.             set startPara to 1
  36.             set endPara to paragraph number of last character
  37.         else
  38.             領域が選択されているとき
  39.             set startPara to paragraph number of selection
  40.             set endPara to paragraph number of last character of selection
  41.         end if
  42.         付加する番号の値を初期値「1」にセットする
  43.         set theNum to 1
  44.         開始パラグラフ番号startParaから終了パラグラフ番号endParaまでループ
  45.         repeat with thePara from startPara to endPara
  46.             番号の値を文字列に変換し区切りマーク": "を付加
  47.             set theString to (theNum as text) & ": "
  48.             番号文字列が指定桁数numLenよりも短いときはパディングマークを挿入する
  49.             repeat while length of theString < numLen + 2
  50.                 set theString to padding & theString
  51.             end repeat
  52.             番号文字列をパラグラフの先頭に挿入する。
  53.             insert theString at beginning of paragraph thePara
  54.             挿入した番号文字列のながさをtheLenにセット
  55.             set theLen to length of theString
  56.             挿入した番号文字列を選択する
  57.             select (characters 1 thru theLen) of paragraph thePara
  58.             選択領域(番号文字列部分)を指定の文字色へ
  59.             set fore color of selection to numColor
  60.             選択領域(番号文字列部分)を指定のフォントへ
  61.             set font of selection to numFont
  62.             選択領域(番号文字列部分)を指定の文字サイズへ
  63.             set fontSize of selection to numSize
  64.             選択領域(番号文字列部分)を指定のスタイルへ
  65.             set style of selection to numFace
  66.             付加する番号の値をインクレメント
  67.             set theNum to theNum + 1
  68.         end repeat
  69.     end tell
  70. end tell